const express = require('express');
// 创建路由模块
var router = express.Router();


// 引用控制器
const pagesControllers = require('./controllers/pagesControllers.js');
const userControllor = require('./controllers/userControllor.js');
const postControllers = require('./controllers/postControllers');
const cateControllers = require('./controllers/cateControllers');
const uploadController = require('./controllers/uploadController');


// 调用方法
// 前台页面
router.get('/',pagesControllers.getIndexPage)
.get('/',pagesControllers.getDetailPage)
.get('/',pagesControllers.getListPage)
// 后台页面
.get('/admin/categories',pagesControllers.getAdiminCategoriesPage)
.get('/admin/comments',pagesControllers.getAdiminCommentsPage)
.get('/admin',pagesControllers.getAdiminIndexPage)
.get('/admin/login',pagesControllers.getAdiminLoginPage)
.get('/admin/nav-menus',pagesControllers.getAdiminNavmenusPage)
.get('/admin/password',pagesControllers.getAdiminPasswordPage)
.get('/admin/post-add',pagesControllers.getAdiminPostaddPage)
.get('/admin/posts',pagesControllers.getAdiminPostsPage)
.get('/admin/profile',pagesControllers.getAdiminProfilePage)
.get('/admin/settings',pagesControllers.getAdiminSettingsPage)
.get('/admin/slides',pagesControllers.getAdiminSlidesPage)
.get('/admin/users',pagesControllers.getAdiminusersPage)
// 业务处理路由
.post('/login',userControllor.login)
.get('/getAllPost',postControllers.getAllPost)
.get('/getAllCate',cateControllers.getAllCate)
.post('/addPost',postControllers.addPost)


// 实现文件上传
.post('/uploadFile',uploadController.uploadFile)



// // 配置路由模块
// // 4.添加路由配置
// router.get('/', (req,res) => {
//     res.render('index.ejs')
// });
// // 4.添加路由配置
// router.get('/admin', (req,res) => {
//    res.render('admin/index.ejs')
// });
// router.get('/admin/categories', (req,res) => {
//     res.render('admin/categories.ejs')
// });
// router.get('/admin/comments',(req,res) => {
//     res.render('admin/comments.ejs')
// });
// router.get('/admin/nav-menus',(req,res) => {
//     res.render('admin/nav-menus.ejs')
// });
// router.get('/admin/password-reset',(req,res) => {
//     res.render('admin/password-reset.ejs')
// });
// router.get('/admin/post-add',(req,res) => {
//     res.render('admin/post-add.ejs')
// });
// router.get('/admin/posts',(req,res) => {
//     res.render('admin/posts.ejs')
// });
// router.get('/admin/profile',(req,res) => {
//     res.render('admin/profile.ejs')
// });
// router.get('/admin/settings',(req,res) => {
//     res.render('admin/settings.ejs')
// });
// router.get('/admin/slides',(req,res) => {
//     res.render('admin/slides.ejs')
// });
// router.get('/admin/users',(req,res) => {
//     res.render('admin/users.ejs')
// });


// 暴露
module.exports = router;